# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key => '_latanova_session_id'
  layout 'standard'
  
  def self.define_model_name( name, article = 'o', plural = nil )
    
    @@model_name = name
    @@model_name_plural = ''
    if plural
      @@model_name_plural = plural
    else
      @@model_name_plural = "#{@@model_name}s"
    end
    @@model_article = article
    
  end

  def model_name
    @@model_name
  end
  
  def model_name_plural
    @@model_name_plural
  end
  
  def model_article
    @@model_article
  end
  
  def new_title    
    @title = "Nov#{@@model_article.downcase} #{model_name}"
  end
  
  def edit_title( value )
    @title = "Editar #@@model_name - #{value}"
  end
  
  def list_title    
    @title = "Lista de #@@model_name_plural"
  end
  
  def show_title( value )
    @title = "Visualizar #@@model_name - #{value}"
  end
  
  def updated_notice
    flash[:notice] = "#{model_article.upcase} #{model_name} foi atualizado#{model_article.downcase} com sucesso"
  end
  
  def created_notice
    flash[:notice] = "#{model_article.upcase} #{model_name} foi criad#{model_article.downcase} com sucesso"
  end
  
end
